package com.lihh.demo;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class RunAsync001
{
    public static void main(String[] args)
    {
        ExecutorService executors = Executors.newFixedThreadPool(1);

        CompletableFuture<Void> runAsync = CompletableFuture.runAsync(() -> {
            System.out.println(Thread.currentThread().getName());
            System.out.println("run async");
            try {
                Thread.sleep(3000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }, executors);

        runAsync.thenRun(() -> System.out.println("next run async"));
    }
}
